home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / QuickTime / Sample Code / QT Image Transcoders / Sample Transcoder / transcoderTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-26  |  2.6 KB  |  124 lines  |  [TEXT/CWIE]

  1. #include <Fonts.h>
  2. #include <Scrap.h>
  3.  
  4. #include <Movies.h>
  5.  
  6. extern void registerTestTranscoder(void);
  7.  
  8. pascal Boolean filter(MovieController mc, short action, void *params, long refCon);
  9.  
  10. void main(void)
  11. {
  12.     OSErr err;
  13.     StandardFileReply reply;
  14.     SFTypeList types;
  15.     Movie m;
  16.     short resFref;
  17.     WindowPtr w;
  18.     Rect bounds;
  19.     Boolean done = false;
  20.     TimeValue time = 0;
  21.     ComponentInstance mc;
  22.     Rect maxBounds = {100, 100, 700, 700};
  23.  
  24.     InitGraf(&qd.thePort);
  25.     InitFonts();
  26.     InitWindows();
  27.     InitMenus();
  28.     TEInit();
  29.     InitDialogs(0L);
  30.     InitCursor();
  31.     MaxApplZone();
  32.  
  33.     registerTestTranscoder();
  34.  
  35.     EnterMovies();
  36.  
  37.     types[0] = MovieFileType;
  38.     StandardGetFilePreview(nil, 1, types, &reply);
  39.     if (!reply.sfGood) return;
  40.  
  41.     SetRect(&bounds, 75, 75, 75+160,75+120);
  42.     w = NewCWindow(nil, &bounds, reply.sfFile.name, false, 0, (WindowPtr)-1,
  43.         true, 0);
  44.     if (!w) return;
  45.  
  46.     SetPort(w);
  47.  
  48.     err = OpenMovieFile(&reply.sfFile, &resFref, fsRdPerm);
  49.     if (err) return;
  50.  
  51.     err = NewMovieFromFile(&m, resFref, nil, (StringPtr)nil,
  52.                 newMovieActive, nil);
  53.     if (err) return;
  54.  
  55.     CloseMovieFile(resFref);
  56.  
  57.     GetMovieBox(m, &bounds);
  58.     OffsetRect(&bounds, -bounds.left, -bounds.top);
  59.     SetMovieBox(m, &bounds);
  60.  
  61.     mc = NewMovieController(m, &bounds, mcTopLeftMovie);
  62.     MCGetControllerBoundsRect(mc, &bounds);
  63.     MCDoAction(mc, mcActionSetKeysEnabled, (void *)1);
  64.     MCSetActionFilterWithRefCon(mc, filter, (long)w);
  65.     
  66.     MCDoAction(mc, mcActionSetGrowBoxBounds, &maxBounds);
  67.     SizeWindow(w, bounds.right, bounds.bottom, false);
  68.  
  69.     ShowWindow(w);
  70.  
  71.     while (done == false) {
  72.         EventRecord theEvent;
  73.         TimeValue nextTime;
  74.  
  75.         GetNextEvent(everyEvent, &theEvent);
  76.         if (MCIsPlayerEvent(mc, &theEvent))
  77.             continue;
  78.  
  79.         switch (theEvent.what) {
  80.             case mouseDown:
  81.                 {
  82.                 WindowPtr whichWindow;
  83.                 short part;
  84.  
  85.                 part = FindWindow(theEvent.where, &whichWindow);
  86.                 switch (part) {
  87.                     case inGoAway:    done = TrackGoAway(whichWindow, theEvent.where);
  88.                                     break;
  89.                     case inDrag:    DragAlignedWindow(whichWindow, theEvent.where,
  90.                                         &qd.screenBits.bounds, nil, nil);
  91.                                     break;
  92.                 }
  93.                 }
  94.                 break;
  95.  
  96.             case activateEvt:
  97.                 SetCursor(&qd.arrow);
  98.                 break;
  99.  
  100.             case updateEvt:
  101.                 BeginUpdate((WindowPtr)theEvent.message);
  102.                 EndUpdate((WindowPtr)theEvent.message);
  103.                 UpdateMovie(m);
  104.                 break;
  105.         }
  106.     }
  107.     ZeroScrap();
  108.     PutMovieOnScrap(m, 0);
  109.     DisposeMovieController(mc);
  110.     DisposeMovie(m);
  111. }
  112.  
  113. pascal Boolean filter(MovieController mc, short action, void *params, long refCon)
  114. {
  115.     if (action == mcActionControllerSizeChanged) {
  116.         Rect bounds;
  117.  
  118.         MCGetControllerBoundsRect(mc, &bounds);
  119.         SizeWindow((void *)refCon, bounds.right, bounds.bottom, false);
  120.     }
  121.  
  122.     return false;
  123. }
  124.